﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LotteCinema.Admin
{
    public partial class Admin : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["QUYEN"] == null)
                Response.Redirect("~/Admin/DangNhap.aspx");
            if (!IsPostBack)
            {
                if (Session["Fix"] != null && (bool)Session["Fix"] == false)
                    lblDatabase.Text = "Fix";
                if (Session["QUYEN"].ToString().Trim() == "Admin")
                {
                    lblquanlyphim.Visible = true;
                    lblqlnhanvien.Visible = true;
                    lbldoimatkhau.Visible = true;
                    lblxemthongtin.Visible = true;
                    Default.Visible = true;
                }
                else
                    if (Session["QUYEN"].ToString().Trim() == "TBP")
                    {
                        lblquanlyphim.Visible = true;
                        lblqlnhanvien.Visible = false;
                        lbldoimatkhau.Visible = true;
                        lblxemthongtin.Visible = true;
                        lblQuanLyVe.Visible = false;
                        lblGiaNiemYet.Visible = false;
                        Default.Visible = true;
                        //Response.Redirect("~/Admin/Default.aspx");
                    }
                    else
                    {
                        if (Session["QUYEN"].ToString() == "QL")
                        {
                            lblquanlyphim.Visible = false;
                            lblqlnhanvien.Visible = false;
                            lbldoimatkhau.Visible = true;
                            lblxemthongtin.Visible = true;
                            lblQuanLyVe.Visible = false;
                            lblGiaNiemYet.Visible = false;
                            //Response.Redirect("~/Admin/Default.aspx");
                        }
                        else
                        {
                            lblquanlyphim.Visible = false;
                            lblqlnhanvien.Visible = false;
                            lbldoimatkhau.Visible = true;
                            lblxemthongtin.Visible = true;
                            lblQuanLyVe.Visible = false;
                            lblGiaNiemYet.Visible = false;
                            //Response.Redirect("~/Admin/Default.aspx");
                        }
                    }
                if (Session["TENDANGNHAP"] != null)
                {
                    lbthoten.Text = "Xin chào : " + Session["TENDANGNHAP"].ToString();
                }
            }
        }

        //protected void Page_Load(object sender, EventArgs e)
       // {
            //if (Session["QUYEN"] == null) Response.Redirect("DangNhap.aspx");
            //if (int.Parse(Session["QUYEN"].ToString()) == 0) Response.Redirect("~/TrangChu.aspx");
            //if (Session["TENDANGNHAP"] != null)
            //{
            //    if (int.Parse(Session["QUYEN"].ToString()) == 1)
            //        lbthoten.Text = "Xin chào : " + Session["TENDANGNHAP"] + " - Administrator";
            //    else if (int.Parse(Session["QUYEN"].ToString()) == 2)
            //    {
            //        lbthoten.Text = "Xin chào : " + Session["TENDANGNHAP"] + " - Moderator";
            //    }
            //}
        //}

        protected void Linkbutton_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/Default.aspx");
        }
        protected void lbtthoat_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("~/Admin/Default.aspx");
        }
        protected void LienHe_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/LienHe.aspx");
        }
        protected void SanPham_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/Phim.aspx");
        }
        protected void NhomSanPham_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/LoaiSanPham.aspx");
        }
        protected void ThongTinCongTy_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/ThongTinCongTy.aspx");
        }
        protected void TuVanTrucTuyen_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/TuVanTrucTuyen.aspx");
        }
        protected void PhanQuyen_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/Quyen.aspx");
        }
        protected void DanhMucMenu_Click(object sender, EventArgs e)
        {
        //    LinkButton lbt = (LinkButton)sender;
        //    Response.Redirect("~/Admin/SanPham.aspx");
        }
        protected void ThayDoiBanner_Click(object sender, EventArgs e)
        {
            //    //LinkButton lbt = (LinkButton)sender;
            //    //Response.Redirect("~/Admins/" + lbt.ID.Trim() + ".aspx");
        }

        protected void lblqlnhanvien_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/NhanVien.aspx");
        }

        protected void lblquanlyphim_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/Phim.aspx");
        }

        protected void lbldoimatkhau_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/DoiMatKhau.aspx");
        }

        protected void lblxemthongtin_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/XemThongTin.aspx");
        }

        protected void lblQuanLyVe_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyVe.aspx");
        }

        protected void lblGiaNiemYet_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/GiaNiemYet.aspx");
        }

        protected void lblQuanLyGhe_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QLGhe.aspx");
        }

        protected void lblQuanLyCaChieu_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyCaChieu.aspx");
        }

        protected void lblQuanLyChucVu_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyChucVu.aspx");
        }

        protected void lblQuanLyDoiTuongXem_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyDoiTuongXem.aspx");
        }

        protected void lblQuanLyLoaiPhong_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyLoaiPhongChieu.aspx");
        }

        protected void lblQuanLyLoaiGhe_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyMaLoaiGhe.aspx");
        }

        protected void lblQuanLyPhongChieu_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyPhongChieu.aspx");
        }

        protected void lblQuanLyQuocGia_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyQuocGia.aspx");
        }

        protected void lblQuanLyRap_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyRapPhim.aspx");
        }

        protected void lblQuanLySuatChieu_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLySuatChieu.aspx");
        }

        protected void lblQuanLyThanhVien_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyThanhVien.aspx");
        }

        protected void lblDatabase_Click(object sender, EventArgs e)
        {
            if ((bool)Session["Fix"] == false)
            {
                Session["Database"] = "QuanLyRapPhim1ConnectionString";
                Session["Fix"] = !(bool)Session["Fix"];
                DAO.global.tendatabase = Session["Database"].ToString();
                lblDatabase.Text = "Error";
            }
            else
            {
                Session["Database"] = "QuanLyRapPhim2ConnectionString";
                Session["Fix"] = !(bool)Session["Fix"];
                DAO.global.tendatabase = Session["Database"].ToString();
                lblDatabase.Text = "Fix";
            }
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lbt = (LinkButton)sender;
            Response.Redirect("~/Admin/QuanLyLichChieuPhim.aspx");
        }
    }
}